﻿
using System;
using Relay.Core.Protocol;
namespace Relay.Core.Plugins {
    /// <summary>
    /// Represents the result of one attempted plugin load operation.
    /// </summary>
    public class PluginLoadResult {
        private bool _success = false;
        private string _message = string.Empty;

        public bool Success {
            get { return _success; }
            set { _success = value; }
        }
        public string Message {
            get { return _message; }
            set { _message = value; }
        }

        public PluginLoadResult(bool success, string message) {
            _success = success;
            _message = message;
        }

        public PluginLoadResult(bool success) : this(true, string.Empty) { }
    }

    /// <summary>
    /// Provides an interface to implement basic plugin functionality for an object.
    /// </summary>
    public interface IPlugin {
        /// <summary>
        /// Perform any initialization that is necessary.
        /// </summary>
        /// <param name="host">The plug-in host that hosts this plug-in.</param>
        PluginLoadResult Initialize(ApplicationService host);

        /// <summary>
        /// Terminate the plugin and clean up any resources that may be open.
        /// </summary>
        void Terminate();

        /// <summary>
        /// Gets the name of the plugin.
        /// </summary>
        string Name { get; }

        /// <summary>
        /// Gets the description of the plugin.
        /// </summary>
        string Description { get; }

        /// <summary>
        /// Gets the author of the plugin.
        /// </summary>
        string Author { get; }

        /// <summary>
        /// Occurs when an error occurs within the plugin.
        /// </summary>
        event EventHandler<MessageEventArgs> Error;

        /// <summary>
        /// Occurs when the plugin has successfully initialized.
        /// </summary>
        event EventHandler<EventArgs> Initialized;
    }
}
